﻿using System;
using Vallelunga.HomeAutomation.X10;

namespace BuildStatusIndicator.X10.Hardware
{
    public class X10SignalIndicator : IX10SignalIndicator

    {
        private readonly CM11A _lavaLamps;

        public X10SignalIndicator()
        {
            _lavaLamps = CM11A.Instance("COM1");
        }

        #region Implementation of IX10SignalIndicator

        public void TurnOnGreen()
        {
            _lavaLamps.SendCommand(X10HouseCode.B, 2, X10Command.TurnOn);
        }

        public void TurnOffGreen()
        {
            _lavaLamps.SendCommand(X10HouseCode.B, 2, X10Command.TurnOff);
        }

        public void TurnOnRed()
        {
            _lavaLamps.SendCommand(X10HouseCode.C, 2, X10Command.TurnOn);
        }

        public void TurnOffRed()
        {
            _lavaLamps.SendCommand(X10HouseCode.C, 2, X10Command.TurnOff);
        }

        #endregion

        #region Implementation of IDisposable

        public void Dispose()
        {
            _lavaLamps.Dispose();
        }

        #endregion
    }
}